﻿@using System.Threading
@using EveKillboard.Content
@using EveKillboard.Core.Views
@model IEnumerable<KillmailView>
@{
    var isKill = (bool)ViewData["isKill"];
    var onclick = ViewData.ContainsKey("onclick") ? (string)ViewData["onclick"] : null;
    var next = ViewData.ContainsKey("next") ? (string)ViewData["next"] : null;
    var previous = ViewData.ContainsKey("previous") ? (string)ViewData["previous"] : null;
}
<div class="navigationBar">
    <div class="navigationLabel">
        @if (onclick != null){
            <a id="listNavLink" class="evelink" onclick="@onclick">@string.Format(Thread.CurrentThread.CurrentUICulture, "{0}", isKill ? Labels.show_losses : Labels.show_kills)</a>    
        }
    </div>
    <div class="navigation">
        <img id="imgPrevious" width="16px" height="16px" src alt/>
        <a id="previous" class="evelink" onclick="@previous">@Labels.previous</a>
        <a id="next" class="evelink" onclick="@next">@Labels.next</a>
        <img id="imgNext" width="16px" height="16px" src alt/>
    </div>
</div>
@foreach (var date in Model.GroupBy(k => k.Date.Date).Select(k => new { Date = k.Key, kills = k.Select(km => km) })){
    <div class="dayblock gradientheader"><img src alt title="@Labels.date"/><label>@string.Format(Thread.CurrentThread.CurrentCulture, "{0:D}", date.Date)</label>|<label>@string.Format(Thread.CurrentThread.CurrentCulture, "{0} {1}", date.kills.Count(), isKill ? Labels.kills : Labels.losses)</label>|<label>@string.Format(EveKillboard.Core.EveCustomFormatProvider.Instance, "{0:N2}", date.kills.Sum(k => k.KillmailValue))</label></div>
    <div class="killsList">
        @foreach (var kill in date.kills){
        <div class="killcontent">
            <div class="killItem">
                <a class="killmaildetails" href="@string.Format("{0}/{1}", Url.Action("details", "Killboard"), kill.Id)">
                    <img src="@string.Format("http://image.eveonline.com/InventoryType/{0}_32.png", kill.DestroyedItemId)" alt width="32px" height="32px"/>
                    <div><div><b>@kill.DestroyedItemName</b></div><div>@kill.DestroyedItemGroup</div></div>
                </a>
            </div>
            <div class="killvictim">
                @if (kill.AllianceId.HasValue){
                    <a class="evelink" href="@string.Format("{0}/{1}", Url.Action("Alliance", "Killboard"), kill.AllianceInternalId.GetValueOrDefault(0))">
                        <img title="@kill.AllianceName" src="@string.Format("http://image.eveonline.com/alliance/{0}_32.png", kill.AllianceId)" alt width="32px" height="32px"/>
                    </a>
                }
                else{
                    <img title="@kill.CorporationName" src="@string.Format("http://image.eveonline.com/corporation/{0}_32.png", kill.CorporationId)" alt width="32px" height="32px"/>    
                }
                <div>
                    <div><a class="evelink" href="@string.Format("{0}/{1}", Url.Action("Pilot", "Killboard"), kill.CharacterInternalId)"><b>@kill.CharacterName</b></a></div>
                    <div><a class="evelink" href="@string.Format("{0}/{1}", Url.Action("Corporation", "Killboard"), kill.CorporationInternalId.GetValueOrDefault(0))">@kill.CorporationName</a></div>
                </div>
            </div>
            <div class="killlocation">
                <img src alt title="@Labels.solar_system"/>
                <div>
                    <div><a class="evelink">@kill.SystemName</a>&nbsp;@string.Format(Thread.CurrentThread.CurrentCulture, "({0:N2})", kill.SystemTrueSecurity)</div>
                    <div><a class="evelink">@kill.RegionName</a></div>
                </div>
            </div>
            <div class="killtime">
                <img src alt title="@Labels.time"/><div>@string.Format(Thread.CurrentThread.CurrentCulture, "{0:t}", kill.Date)</div>
            </div>
            <div class="killInvolved">
                <img src alt title="@Labels.involved"/><div>@kill.InvolvedCount</div>
            </div>
            <div class="killValue">
                <img src alt title="@Labels.value"/>
                <div>@string.Format(EveKillboard.Core.EveCustomFormatProvider.Instance, "{0:N2}", kill.KillmailValue)</div>
            </div>
        </div>
        }
    </div>
}